package com.example.mapper;

import com.example.entity.SkuAttrValue;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @author 12057
* @description 针对表【sku_attr_value(sku销售属性&值)】的数据库操作Mapper
* @createDate 2024-05-13 13:47:41
* @Entity com.example.entity.SkuAttrValue
*/
@Mapper
public interface SkuAttrValueMapper extends BaseMapper<SkuAttrValue> {

    @Select("select attr_id,attr_name,attr_value from sku_attr_value where sku_id = #{skuId} order by sort asc")
    List<SkuAttrValue> getSkuAttrsBySkuId(@Param("skuId") Long skuId);

    @Select("select attr_id,attr_name,attr_value from admin_sku_attr_value_exam where sku_id = #{skuId} order by sort asc")
    List<SkuAttrValue> getExamSkuAttrsBySkuId(@Param("skuId") Long skuId);

    @Select("SELECT attr_name AS 'key', attr_value AS 'value' FROM sku_attr_value WHERE sku_id = #{skuId}")
    List<Map<String, String>> findSaleAttrsBySkuId(Long skuId);
}




